#!/bin/bash

echo "🔍 热点追踪系统部署检查..."

# 检查Docker服务
echo "📦 检查Docker容器状态..."
docker-compose ps

echo ""
echo "🏥 检查服务健康状态..."

# 检查Redis健康状态
echo "📊 Redis状态:"
docker-compose exec redis redis-cli ping || echo "❌ Redis连接失败"

# 检查后端API健康状态
echo "🔧 后端API状态:"
curl -f http://localhost:3001/api/health || echo "❌ 后端API健康检查失败"

# 检查前端状态
echo "🌐 前端状态:"
curl -f http://localhost/health || echo "❌ 前端健康检查失败"

# 检查API数据获取
echo "📊 测试API数据获取:"
curl -f "http://localhost:3001/api/hotspots?platform=weibo" || echo "❌ API数据获取失败"

echo ""
echo "📋 查看容器日志 (最近20行):"
echo "=== 后端日志 ==="
docker-compose logs --tail=20 api

echo ""
echo "=== 前端日志 ==="
docker-compose logs --tail=20 frontend

echo ""
echo "=== Redis日志 ==="
docker-compose logs --tail=20 redis

echo ""
echo "✅ 检查完成！"